home *** CD-ROM | disk | FTP | other *** search
/ Delphi Informant Complete 1995 - 2000 / Delphi Informant Complete 1995 to 2000.iso / Delphi Informant Magazine Complete Works SOURCE CODE 1998.rar / 1998 / Jul / DI9807NU / StatLnB.pas < prev   
Pascal/Delphi Source File  |  1998-03-19  |  6KB  |  183 lines

  1. { Listing One }
  2. unit StatLnB; { Customized, stand-alone version of Statln feature }
  3.  
  4. interface
  5.  
  6. uses
  7.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  8.   RzStatus, ExtCtrls, RzPanel, Featcomp, StdCtrls;
  9.  
  10. type
  11. { These classes are used by Propel to store the property data for each
  12.   array connection }
  13.   TStatusLineSpecialPropObj = class(TFeatureArrayPropObj)
  14.   private
  15.     FGlyphMessage: String;
  16.     FGlyphToShow: TBitmap;
  17.     procedure SetGlyphToShow(Value: TBitmap);
  18.   public
  19.     constructor CreatePropObj(Feature: TCustomFeature;
  20.                               ConnectionName: string;
  21.                               IndexInArray: integer); override;
  22.     destructor Destroy; override;
  23.   published
  24.   { These property names and types must match the names and types in the
  25.     normal (Propel-native) feature }
  26.     property GlyphMessage: String read FGlyphMessage write FGlyphMessage;
  27.     property GlyphToShow: TBitmap read FGlyphToShow write SetGlyphToShow;
  28.   end;
  29.  
  30.   TStatusLineSpecialPropObj1 = class(TFeatureArrayPropObj)
  31.   private
  32.     FStatusMessage: String;
  33.   public
  34.     constructor CreatePropObj(Feature: TCustomFeature;
  35.                               ConnectionName: string;
  36.                               IndexInArray: integer); override;
  37.     destructor Destroy; override;
  38.   published
  39.   { This property name and type must match the name and type in the
  40.     normal (Propel-native) feature }
  41.     property StatusMessage: String read FStatusMessage write FStatusMessage;
  42.   end;
  43.  
  44. { Define Custom Feature Class }
  45.   TStatusLineSpecial = class(TCustomFeature)
  46.   protected
  47.    { This procedure is where we connect the published properties Button1Props
  48.      and Button2Props to the TFeatureArrayPropObj class for storage }
  49.     procedure DefineArrayProperties(Proc: TDefineArrayPropertiesProc); override;
  50.   public
  51.     constructor Create(AOwner: TComponent);  override;
  52.   published
  53.   { These properties allow users to edit the array properties in
  54.     the object inspector }
  55.     property Button1Props: TFeatureArrayProperty read GetFeatArrayProp
  56.              write SetFeatArrayProp stored false;
  57.     property Button2Props: TFeatureArrayProperty read GetFeatArrayProp
  58.              write SetFeatArrayProp stored false;
  59.   end;
  60.  
  61. { Define Feature Itself }
  62.   TStatusLineFeature = class(TForm)
  63.     RzStatusBar1: TRzStatusBar;
  64.     RzStatusPane1: TRzStatusPane;
  65.     RzResourceStatus1: TRzResourceStatus;
  66.     RzClockStatus1: TRzClockStatus;
  67.     RzGlyphStatus1: TRzGlyphStatus;
  68.     ArrayConnector1: TArrayConnector;
  69.     Button1: TButton;
  70.     ArrayConnector2: TArrayConnector;
  71.     Button2: TButton;
  72.     FeatureDef1: TFeatureDef;
  73.     procedure Button1MouseMove(Sender: TObject; Shift: TShiftState; X,
  74.       Y: Integer);
  75.     procedure Button2Click(Sender: TObject);
  76.   private { Propel-managed fields }
  77.     FGlyphMessage: String;
  78.     FGlyphToShow: TBitmap;
  79.   published { Propel-managed properties }
  80.     property GlyphMessage: String read FGlyphMessage write FGlyphMessage;
  81.             {array  Button2}
  82.     property GlyphToShow: TBitmap read FGlyphToShow write FGlyphToShow;
  83.             {array  Button2}
  84.   end;
  85.  
  86.   procedure Register;
  87.  
  88. var
  89.   StatusLineFeature: TStatusLineFeature;
  90.  
  91. implementation
  92.  
  93. {$R *.DFM}
  94.  
  95. constructor TStatusLineSpecialPropObj.CreatePropObj(Feature: TCustomFeature;
  96.                                                     ConnectionName: string;
  97.                                                     IndexInArray: integer);
  98.  
  99. begin
  100.   inherited CreatePropObj(Feature,ConnectionName,IndexInArray);
  101.   FGlyphToShow := TBitmap.Create;
  102. end;
  103.  
  104. destructor TStatusLineSpecialPropObj.Destroy;
  105.  
  106. begin
  107.   FGlyphToShow.Free;
  108.   inherited Destroy;
  109. end;
  110.  
  111. procedure TStatusLineSpecialPropObj.SetGlyphToShow(Value: TBitmap);
  112.  
  113. begin
  114.   FGlyphToShow.Assign(Value);
  115. end;
  116.  
  117. constructor TStatusLineSpecial.Create(AOwner : TComponent);
  118.  
  119. begin
  120.   inherited Create (AOwner);
  121.   FeatureClass := 'TStatusLineFeature';
  122. end;
  123.  
  124. constructor TStatusLineSpecialPropObj1.CreatePropObj(Feature: TCustomFeature;
  125.                                                     ConnectionName: string;
  126.                                                     IndexInArray: integer);
  127.  
  128. begin
  129.   inherited CreatePropObj(Feature,ConnectionName,IndexInArray);
  130. end;
  131.  
  132. destructor TStatusLineSpecialPropObj1.Destroy;
  133.  
  134. begin
  135.   inherited Destroy;
  136. end;
  137.  
  138. procedure TStatusLineSpecial.DefineArrayProperties(Proc:
  139.                               TDefineArrayPropertiesProc);
  140.  
  141. begin
  142.   Proc('Button1Props','Button1',TStatusLineSpecialPropObj1);
  143.   Proc('Button2Props','Button2',TStatusLineSpecialPropObj);
  144. end;
  145.  
  146. procedure TStatusLineFeature.Button1MouseMove(Sender: TObject;
  147.   Shift: TShiftState; X, Y: Integer);
  148. var
  149.    PropObj: TStatusLineSpecialPropObj1;
  150. begin
  151.   If not Assigned(RzStatusPane1) then
  152.     Exit;
  153.   PropObj := TStatusLineSpecialPropObj1(FeatureDef1.GetArrayPropObject
  154.              ('Button1Props', 'Button1', ArrayConnector1.IndexOf(Sender)));
  155.   If PropObj = nil then
  156.     Exit;
  157.   RzStatusPane1.Caption := PropObj.StatusMessage;
  158. end;
  159.  
  160. procedure TStatusLineFeature.Button2Click(Sender: TObject);
  161. var
  162.    PropObj: TStatusLineSpecialPropObj;
  163. begin
  164.   If not Assigned(RzGlyphStatus1) then
  165.     Exit;
  166.   PropObj := TStatusLineSpecialPropObj(FeatureDef1.GetArrayPropObject
  167.              ('Button2Props', 'Button2', ArrayConnector2.IndexOf(Sender)));
  168.   If PropObj = nil then
  169.     Exit;
  170.   If PropObj.GlyphToShow <> nil then
  171.     RzGlyphStatus1.Glyph := PropObj.GlyphToShow;
  172.   RzGlyphStatus1.Caption := PropObj.GlyphMessage;
  173. end;
  174.  
  175. procedure Register;
  176. begin
  177.   RegisterComponents('Features',[TStatusLineSpecial]);
  178. end;
  179.  
  180. initialization
  181.   RegisterFeature(TStatusLineFeature);
  182. end.
  183.